<?php
class Form_AjoutPhoto extends Zend_Form
{
    public function init()
	{
		$this -> setMethod('post');
		$this -> setName('ajoutphoto');
		
		$vip = new Zend_Form_Element_Select('vip');
		$vip	-> setLabel('Nom du VIP: ')
		 		-> setRequired(true);
		$this -> addElement($vip);
		
		$img = new Zend_Form_Element_File("img");
        $img->setLabel('Adresse de la photo :')
            ->setRequired(true)
			->addValidator('Count', false, 1)
			->addValidator('Extension', false, 'jpg,png,gif')
			->setDestination('../public/images/');
		$this->addElement($img);
		
		
		$sujet = new Zend_Form_ELement_Text('sujet');
		$sujet -> setLabel("Titre :")
			    ->addFilter('StripTags')
				->addFilter('StringToLower')
				->addValidator('StringLength', false,array(3 ,20))
				->addValidator('alnum')
				->addValidator('regex', false, array('/^[a-z]+/'))
				->addFilter('StringTrim')
				->setRequired(true);
		$this -> addElement($sujet); //Attache au formulaire
		
		$commentaire = new Zend_Form_Element_Textarea('commentaire');
		$commentaire -> setLabel("Un petit commentaire?")
			    ->setAttrib('cols','40')
				->setAttrib('rows','4')
				->setRequired(true);
		$this -> addElement($commentaire); //Attache au formulaire
		
		
		
		
        $submitButton = new Zend_Form_Element_Submit('Ajouter');
		$this -> addElement($submitButton); //Attache au formulaire
		
		$resetButton = new Zend_Form_Element_Reset('Annuler');
		$this -> addElement($resetButton); //Attache au formulaire
	}

	public function remplirListeVip($resu){
		foreach ($resu as $ligne)
		{
			$this->vip->addMultiOption($ligne->VIP_NUMERO,$ligne->VIP_PRENOM." ".$ligne->VIP_NOM);
		}
	}	
}
?>
